<template>
	<view class="content">
		<Header>
			提案工作
		</Header>
		<liuyuno-tabs :tabData="tabs" :activeIndex="defaultIndex" @tabClick='tabClick' />
		<view style="height: calc(100vh - 86px - var(--status-bar-height));" >
			<MyProposal v-if="defaultIndex == 0"></MyProposal>
			<ProposalForm :id="proposalId" v-if="defaultIndex == 1"></ProposalForm>
			<ProposalDraft v-if="defaultIndex == 2"></ProposalDraft>
			<OpenProposal v-if="defaultIndex == 3"></OpenProposal>
		</view>
	</view>
</template>

<script>
	import Header from '../../components/header.vue'
	import Footer from '../../components/footer.vue'
	import liuyunoTabs from "@/components/liuyuno-tabs/liuyuno-tabs.vue";
	import MyProposal from './myProposal.vue'
	import ProposalForm from './proposalForm.vue'
	import ProposalDraft from './proposalDraft.vue'
	import OpenProposal from './openProposal.vue'
	export default {
		components: {
			Header,
			Footer,
			liuyunoTabs,
			MyProposal,
			ProposalForm,
			ProposalDraft,
			OpenProposal,
		},
		data() {
			return {
				tabs: ['我的', '提交', '草稿', '公开'],
				defaultIndex: 0,
				proposalId: '',
				opinionId: '',
			}
		},
		onLoad() {

		},
		mounted() {
			uni.$on('showContent', (data) => {
				if (data.page == 'form') {
					this.proposalId = ''
					if (data.type == 1) {
						this.defaultIndex = 0
					} else {
						this.defaultIndex = 2
					}
				} else if (data.page == 'draft') {
					this.defaultIndex = 1
					this.proposalId = data.id
				}
			})
		},
		methods: {

			tabClick(index) {
				if(index != 1) this.proposalId = ''
				this.defaultIndex = index
			}
		}
	}
</script>

<style scoped>
	::v-deep ._tab-box::after {
		position: absolute;
		bottom: 0;
		right: 0;
		left: 0;
		height: 1px;
		content: "";
		transform: scaleY(0.5);
		background-color: #e5e5e5;
	}
	::v-deep ._item {
		font-weight: normal !important;
	}

	::v-deep ._item._active {
		font-weight: bold !important;
	}
</style>